package demo2;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;


public class Test {

    public static void main(String[] args) {
        LocalDateTime currentDate = LocalDateTime.now();
        LocalDateTime firstDayOfMonth =
                currentDate.with(TemporalAdjusters.firstDayOfMonth());
        LocalDateTime lastDayOfMonth =
                currentDate.with(TemporalAdjusters.lastDayOfMonth());
        System.out.println(firstDayOfMonth);
        System.out.println(lastDayOfMonth);
    }


    public static void main11(String[] args) {
        LocalDateTime currentDate = LocalDateTime.now();

        // 获取当前日期所在的当周周一
        LocalDateTime firstDayOfWeek = currentDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));

        LocalDateTime lastDayOfWeek = currentDate.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));

        System.out.println(firstDayOfWeek);
        System.out.println(lastDayOfWeek);
    }

    public static void main10(String[] args) {
        LocalDateTime dateTime = LocalDateTime.of(2025,3,30,21,25);

        LocalDateTime newDataPlus = dateTime.plusMonths(1);
        System.out.println("增加1月后的日期:" + newDataPlus);

        LocalDateTime newDataMinus = dateTime.minusMonths(1);
        System.out.println("减少1月后的日期:" + newDataMinus);
    }

    public static void main9(String[] args) {
        LocalDateTime dateTime = LocalDateTime.now();
        System.out.println(dateTime);

        LocalDateTime newDataPlus = dateTime.plusYears(1);
        System.out.println("增加1年后的日期:" + newDataPlus);

        LocalDateTime newDataMinus = dateTime.minusYears(1);
        System.out.println("减少1年后的日期:" + newDataMinus);
    }

    public static void main8(String[] args) {
        LocalDateTime dateTime = LocalDateTime.now();
        System.out.println(dateTime);

        LocalDateTime newDataPlus = dateTime.plusMonths(1);
        System.out.println("增加1月后的日期:" + newDataPlus);

        LocalDateTime newDataMinus = dateTime.minusMonths(1);
        System.out.println("减少1月后的日期:" + newDataMinus);
    }

    public static void main7(String[] args) {
        LocalDateTime dateTime = LocalDateTime.now();
        System.out.println(dateTime);

        LocalDateTime newDataPlus = dateTime.plusWeeks(1);
        System.out.println("增加1周后的日期:" + newDataPlus);

        LocalDateTime newDataMinus = dateTime.minusWeeks(1);
        System.out.println("减少1周后的日期:" + newDataMinus);
    }

    public static void main6(String[] args) {
        LocalDateTime localDateTime = LocalDateTime.now();
        LocalDateTime newDataPlus = localDateTime.plusDays(1);
        System.out.println("增加1天后的日期:"+newDataPlus);

        LocalDateTime newDataMinus = localDateTime.minusDays(1);
        System.out.println("减少1天后的日期:"+newDataMinus);
    }

    public static void main5(String[] args) {
        LocalDateTime dateTime = LocalDateTime.now();
        System.out.println("当前日期为:"+dateTime);

        System.out.println("本周周几:"+dateTime.getDayOfWeek());

        System.out.println("本月第几天:"+dateTime.getDayOfMonth());

        System.out.println("当年第几天:"+dateTime.getDayOfYear());

    }

    public static void main4(String[] args) {
        LocalDateTime localDateTime = LocalDateTime.of(1998,9,10,21,21,34);
        System.out.println("当前日期为:"+localDateTime);

        String stringData = "2026-10-01 10:30:21";
        // 创建一个自定义的日期时间格式化器
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        LocalDateTime dateTime = LocalDateTime.parse(stringData, dateTimeFormatter);
        System.out.println("当前日期为:" + dateTime);
    }

    public static void main3(String[] args) {
        LocalDateTime localDateTime = LocalDateTime.now();
        int year = localDateTime.getYear();
        int monthValue = localDateTime.getMonthValue();

        System.out.println("year:"+year);
        System.out.println("monthValue:"+monthValue);

        int day = localDateTime.getDayOfMonth();
        System.out.println("day:"+day);

        day = localDateTime.getDayOfYear();
        System.out.println("day:" + day);

        int hour = localDateTime.getHour();
        int minute = localDateTime.getMinute();
        int sceond = localDateTime.getSecond();

        System.out.println("hour:" + hour);
        System.out.println("minute:" + minute);
        System.out.println("sceond:" + sceond);
    }

    public static void main2(String[] args) {
        // LocalDateTime localDateTime = new LocalDataTime();
        LocalDateTime localDateTime1 = LocalDateTime.now();
        System.out.println(localDateTime1);

        LocalDateTime localDateTime2 = LocalDateTime.of(2025,3,26,21,20);
        System.out.println(localDateTime2);

        LocalDateTime parsed = LocalDateTime.parse("2026-05-15T10:30:00");
        System.out.println(parsed);
    }

    public static void main1(String[] args) {
        /*Date date = new Date(123,9,8);
        System.out.println(date);*/

        Date date1 = new Date();
        System.out.println(date1);

        // LocalData和LocalDataTime
    }
}
